unit SaveParams;

interface
uses
  uNeuralNetwork;

type
TSaveParams = class
  private

  public
    Eta         : Double ;
    Epoca       : Integer ;
    Momento     : Double ;
    SizeInput   : Integer ;
    SizeLayer1  : Integer ;
    SizeLayer2  : Integer ;
    BiasLayer1  : String ;
    BiasLayer2  : String ;
    WLayer1     : String ;
    WLayer2     : String ;
    MaxIt       : Integer ;

    procedure SetParams ( PNN : TNeuralNetwork ) ;

  end;

implementation

uses
  SysUtils;

{ TSaveParams }

procedure TSaveParams.SetParams(PNN: TNeuralNetwork);
var
  i , j   : Integer ;
begin
  SizeInput       := PNN.SizeInput ;
  SizeLayer1      := PNN.SizeLayer1 ;
  SizeLayer2      := PNN.SizeLayer2 ;

  Eta := PNN.Eta ;
  Momento := PNN.Mu ;

  for i := 0 to PNN.BiasLayer1.RowCount - 1 do
  begin
    for j := 0  to PNN.BiasLayer1.ColCount - 1 do
    begin
      if ( ( i = 0 ) and ( j = 0 ) ) then
        BiasLayer1  := FloatToStr (PNN.BiasLayer1[i,j])
      else
        BiasLayer1  := BiasLayer1 + ';' + FloatToStr (PNN.BiasLayer1[i,j]) ;
    end;
  end;

  for i := 0 to PNN.BiasLayer2.RowCount - 1 do
  begin
    for j := 0  to PNN.BiasLayer2.ColCount - 1 do
    begin
      if ( ( i = 0 ) and ( j = 0 ) ) then
        BiasLayer2  := FloatToStr (PNN.BiasLayer2[i,j])
      else
        BiasLayer2  := BiasLayer2 + ';' + FloatToStr (PNN.BiasLayer2[i,j]) ;
    end;
  end;

  for i := 0 to PNN.WeightsLayer1.RowCount - 1 do
  begin
    for j := 0  to PNN.WeightsLayer1.ColCount - 1 do
    begin
      if ( ( i = 0 ) and ( j = 0 ) ) then
        WLayer1  := FloatToStr (PNN.WeightsLayer1[i,j])
      else
        WLayer1  := WLayer1 + ';' + FloatToStr (PNN.WeightsLayer1[i,j]) ;
    end;
  end;

  for i := 0 to PNN.WeightsLayer2.RowCount - 1 do
  begin
    for j := 0  to PNN.WeightsLayer2.ColCount - 1 do
    begin
      if ( ( i = 0 ) and ( j = 0 ) ) then
        WLayer2  := FloatToStr (PNN.WeightsLayer2[i,j])
      else
        WLayer2  := WLayer2 + ';' + FloatToStr (PNN.WeightsLayer2[i,j]) ;
    end;
  end;

end;

end.
